package com.woniuxy.services.impl;

import com.woniuxy.daos.ClientDao;
import com.woniuxy.daos.CompanyDao;
import com.woniuxy.entitys.Client;
import com.woniuxy.entitys.Company;
import com.woniuxy.services.ClientService;
import com.woniuxy.services.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ClientServiceImpl implements ClientService {

    @Autowired
    private ClientDao clientDao;

    @Override
    public List<Client> selAll() {
        return clientDao.selAll();
    }


    @Override
    public List<Client> selAllByComId(String com_id) {
        return clientDao.selAllByComId(com_id);
    }

    @Override
    public Client selectByPrimaryKey(Integer cli_id) {
        return clientDao.selectByPrimaryKey(cli_id);
    }

    @Override
    public Integer updateByPrimaryKey(Client client) {
        return clientDao.updateByPrimaryKey(client);
    }

    @Override
    public Integer updCliStatus(String cli_id, String cli_status) {
        return clientDao.updCliStatus(cli_id,cli_status);
    }

    @Override
    public List<Client> searchById(String name, String com_id) {
        return clientDao.searchById(name,com_id);
    }

    //添加新联系人，设置默认status为1
    @Override
    public Integer addClient(Client client) {
        client.setCli_status(1);
        return clientDao.insertSelective(client);
    }
}
